package com.matt.order.controller;

import com.matt.order.dto.OrderDto;
import com.matt.order.service.OrderEnterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/orderList")
public class OrderListController {
    @Autowired
    OrderEnterService orderEnterService;

    @RequestMapping("/init")
    public String orderListInit(Model model) {
        List<OrderDto> orderList = orderEnterService.orderInfoList();
        List<OrderDto> orderGameSumInfoList = orderEnterService.orderGameSumInfoList();
        List<OrderDto> orderLevelSumInfoList = orderEnterService.orderLevelSumInfoList();
        OrderDto orderSumInfo = orderEnterService.orderSumInfo();
        if (orderSumInfo == null) {
            orderSumInfo = new OrderDto();
        }
        String orderEvaluateSumInfo = orderEnterService.orderEvaluateSumInfo();
        model.addAttribute("orderList", orderList);
        model.addAttribute("orderSumInfo", orderSumInfo);
        model.addAttribute("orderGameSumInfoList", orderGameSumInfoList);
        model.addAttribute("orderLevelSumInfoList", orderLevelSumInfoList);
        model.addAttribute("orderEvaluateSumInfo", orderEvaluateSumInfo);
        return "order/order-list";
    }
}
